<template xmlns="http://www.w3.org/1999/html" xmlns:font-family="http://www.w3.org/1999/xhtml">
  <div style="width: 100%;background-color:#ebeeea">
    <div  style="width: 60%;margin-left: 20%;">
      <el-container>
        <el-header style="height:100px;width: 100%">
          <div style="width: 100%;height: 100% ">


            <div style="width: 20%; height:100%;background-color: royalblue;float: left"></div>


            <div style="width: 60%; height:100%;float: left">
              <div style="margin-top: 15px;width:70%;margin-left: 20%">
                <el-input placeholder="请输入内容" v-model="input5" class="input-with-select"  @keyup.enter.native="searchh">
                  <el-select v-model="select" slot="prepend" placeholder="请选择">
                    <el-option label="项目" value="1"></el-option>
                    <el-option label="工作室" value="2"></el-option>
                  </el-select>
                  <!--<el-button type="primary" slot="append" icon="el-icon-search">搜索</el-button>-->
                  <el-button slot="append" icon="el-icon-search" style="background-color: #409EFF" @click="searchh()" ></el-button>
                </el-input>
              </div>

            </div>



            <div style="width: 10%; height:100%;float: left;margin-left: 10%">
              <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" active-text-color="whitesmoke" :collapse="isCollapse" :menu-trigger="click" style="margin-right: 0px;margin-top: 15px">
                <el-submenu index="1" style="background-color: whitesmoke;width: 70px ;" circle>
                  <template slot="title">
                    <el-button type="primary" icon="el-icon-tickets" circle></el-button>
                  </template>
                  <el-menu-item-group style="width: 100px" >
                    <el-menu-item index="1-2" @click="jump('Home')" >返回主页</el-menu-item>
                    <el-menu-item index="1-2" @click="Home()" >后台管理</el-menu-item>
                  </el-menu-item-group>
                </el-submenu>
              </el-menu>
            </div>
          </div>
        </el-header>

        <el-main style="height: 90px;background-color: #ebeeea;margin-top: 32px;line-height: 40px">
            <div style="background-color: white;height: 100%;text-align: left;position: relative">
              <div style="height: 60%;margin-top: 30px;position: absolute;width: 100%">
                <span style="font-size: 25px;margin: auto">消息列表</span>
                <el-button style="float: right; padding: 3px 0" type="text">全部已读</el-button>
              </div>

            </div>
        </el-main>

        <el-main style="height: 650px;background-color: #ebeeea;margin-top: 22px;line-height: 40px">

          <el-card class="box-card" style="line-height: 40px; text-align: left;border: 1px;margin-top: 20px">
            <!--<div slot="header" class="clearfix">-->
              <!--<span style="font-size: 20px">消息列表</span>-->
              <!--<el-button style="float: right; padding: 3px 0" type="text">全部已读</el-button>-->
            <!--</div>-->
            <div v-for="table in tableData" :key="o" class="text item" style="border: 1px;margin-top: 10px; width: 100%;height: 70px; box-shadow: 0 6px 4px rgba(0, 0, 0, .15), 0 0 6px rgba(0, 0, 0, .06)">
              <div v-if="table.xiansi" style="width: 100%;height: 90%;border: 1px"@click="jumpp(table.fid,table.fromname)">
                <el-badge value="new" class="item">
                  {{'来自 ' + table.fromname+"消息"}}
                </el-badge>
              </div>
              <div v-if="table.bx" style="width: 100%;height: 90%;border: 1px"@click="jumpp(table.fid,table.fromname,)">
                  {{'来自 ' + table.fromname+"消息"}}
              </div>
            </div>
          </el-card>
        </el-main>

      </el-container>
    </div>
  </div>
</template>





<script>
  export default {
    data() {
      return {
        leirong:'',
        panduan:'',
        role1:'',
        role2:'',
        role3:'',
        isCollapse: true,
        input: '',
        value4:true,
        input5: '',
        select: '',
        id:'',
        tableData: [
          {
            id:'',
            fromname:'',
            fid:'',
            xiansi:false,
            bx:false,
          }
        ]


      };
    },
    mounted: function(){
      var user= JSON.parse(window.sessionStorage.getItem("user"));
      var ff=user.id
      this.id=ff
      axios.post('/user/lookMassage',{
        tid:ff,
        fid:ff
      }).then((response) => {

        if(response.data!=null||response.data!=""){
          console.log(response.data)
          var e=response.data;

          var data=[];
          for(var c=0;c<e.length;c++){

            var ee=e[c];
            var obj={}
            var zz=ee.states
            if(zz==0){
              obj.xiansi=true,
              obj.bx=false
              obj.fid=ee.fid
              obj.fromname=ee.fromName
              data[c]=obj
              console.log(obj)
            }else{
              obj.xiansi=false,
                obj.bx=true
              obj.fid=ee.fid
              obj.fromname=ee.fromName
              data[c]=obj
              console.log(obj)

            }
          }
          this. tableData=data




        } else{
          this.$notify.error({
            title: '错误',
            message: '错误',
            type: 'warning',
            duration:0
          });
        }
      }).catch((response)=>{

      })



    },
    methods: {
      jump(path){
        this.$router.replace({path:path})

      },
      search(index){
        var e
        var w=1
        if(this.value4==true){
          e="项目"
        }else{
          e="工作室"
        }
        this.$router.push({
          path: '/Search',
          query: {
            mallCode: index,
            mallCode2: e,
            mallCode3:w
          }
        })

      },
      searchh(){
        var e
        var w=2
        if(this.select=="1"){
          e="项目"
        }else{
          e="工作室"
        }
        if(e==""){
          this.$notify({
            title: '警告',
            message: '请选择搜索类型',
            type: 'warning',
            duration:2000
          });
        }
        this.$router.push({
          path: '/Search',
          query: {

            mallCode: this.input5,
            mallCode2: e,
            mallCode3:w
          }
        })

      },
      jumpp(fid,name) {
          this.$router.push({
            path: '/SendMassage',
            query: {
              fid: fid,
              tid: this.id,
              name:name
            }
          })



        }

      },
      Home(){
        var user= JSON.parse(window.sessionStorage.getItem("user"));
        if(user==null||user==""){
          this.$router.replace('/Login')
        }else{
          var role=user.role
          console.log(role)

          if(role==="admin"){
            this.$router.replace('/AdminHome')
          }else{
            this.$router.replace('/Home')
          }}


      },
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },


  }
</script>




<style scoped>
  .text {
    font-size: 18px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 99%;
  }
  .item {
    margin-top: 0px;
    margin-right: 10px;
  }
  .el-header, .el-footer {
    background-color: whitesmoke;
    color: #fff;
    text-align: center;
    line-height: 60px;
    border-right: 1px;
    border-color: royalblue;
  }
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
    width:300px;

  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
    padding: 0px;
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  body > .el-container {
    margin-bottom: 10px;
  }
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .el-select .el-input {
    width: 100px;
  }
  .input-with-select .el-input-group__prepend {

  }

</style>
